package com.log4jviewer.domain;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Assert;
import org.junit.Test;

public class LogFieldTest {

    @Test
    public void logFieldInfoTest() {
        LogEvent mock = mock(LogEvent.class);

        when(mock.getLevel()).thenReturn("INFO");
        Assert.assertEquals("Level", LogField.LEVEL.getName());
        Assert.assertEquals("INFO", LogField.LEVEL.getFieldInfo(mock));

        when(mock.getCategoryName()).thenReturn("CategoryName");
        Assert.assertEquals("Category", LogField.CATEGORY.getName());
        Assert.assertEquals("CategoryName", LogField.CATEGORY.getFieldInfo(mock));

        when(mock.getMessage()).thenReturn("Message");
        Assert.assertEquals("Message", LogField.MESSAGE.getName());
        Assert.assertEquals("Message", LogField.MESSAGE.getFieldInfo(mock));

        when(mock.getLineNumber()).thenReturn("7");
        Assert.assertEquals("Line", LogField.LINE.getName());
        Assert.assertEquals("7", LogField.LINE.getFieldInfo(mock));

        when(mock.getDate()).thenReturn("2011-12-03 10:25:32");
        Assert.assertEquals("Date", LogField.DATE.getName());
        Assert.assertEquals("2011-12-03 10:25:32", LogField.DATE.getFieldInfo(mock));

        when(mock.getNdc()).thenReturn("Ndc");
        Assert.assertEquals("NDC", LogField.NDC.getName());
        Assert.assertEquals("Ndc", LogField.NDC.getFieldInfo(mock));

        when(mock.getThrowableInfo()).thenReturn("Throwable");
        Assert.assertEquals("Throwable", LogField.THROWABLE.getName());
        Assert.assertEquals("Throwable", LogField.THROWABLE.getFieldInfo(mock));
    }
}
